package cn.cdeden.system.dubbo;

import cn.cdeden.common.core.utils.MapstructUtils;
import cn.cdeden.system.api.RemoteRoleService;
import cn.cdeden.system.api.domain.vo.RemoteRoleVo;
import cn.cdeden.system.domain.vo.SysRoleVo;
import cn.cdeden.system.service.ISysRoleService;
import lombok.RequiredArgsConstructor;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.stereotype.Service;

import java.util.List;

@RequiredArgsConstructor
@Service
@DubboService
public class RemoteRoleServiceImpl implements RemoteRoleService {


    private final ISysRoleService sysRoleService;

    @Override
    public List<RemoteRoleVo> selectUserRoleByUserId(Long userId) {
        List<SysRoleVo> sysRoleVos = sysRoleService.selectRolesByUserId(userId);
        return MapstructUtils.convert(sysRoleVos, RemoteRoleVo.class);
    }

    @Override
    public RemoteRoleVo getById(Long roleId) {
        SysRoleVo sysRoleVos = sysRoleService.selectRoleById(roleId);
        return MapstructUtils.convert(sysRoleVos, RemoteRoleVo.class);
    }
}
